<?php
abstract class Zend_Db_Tree_Node_ContainerAbstract implements RecursiveIterator, Countable 
{
    protected $_nodes = array();

    protected $_table;

    public function __construct(array $options = array())
    {
        if (!isset($options['table'])) {
            require_once 'Zend/Db/Tree/Node/Exception.php';
            throw new Zend_Db_Tree_Node_Exception("Option 'table' was not provided");
        }
        $this->_table = $options['table'];

        if (isset($options['children'])) {
            $this->addNodes($options['children']);
        }
    }

    public function addNodes(array $nodes)
    {
        foreach ($nodes as $info) {
            $class = get_class($this);
            $info['table'] = $this->_table;
            $node = new $class($info);
            $this->addNode($node);
        }
    }

    public function addNode(Zend_Db_Tree_Node $node)
    {
        $this->_nodes[] = $node;
        return $this;
    }

    public function getChildren()
    {
    }

    public function hasChildren()
    {
    }

    public function current()
    {
    }

    public function key()
    {
    }

    public function next()
    {
    }

    public function rewind()
    {
    }

    public function valid()
    {
    }

    public function count()
    {
        return count($this->_nodes);
    }

    public function toArray()
    {
        $result = array();
        foreach ($this->_nodes as $node) {
            $result[] = $node->toArray();
        }
        return $result;
    }
}
